package tv.athena.live.api.chatroom

import android.arch.lifecycle.Observer
import tv.athena.live.api.channel.ChatRoomCallback
import tv.athena.live.base.arch.IComponentApi
import java.util.LinkedList
import kotlin.collections.HashMap

/**
 * Created by xudadade on 2019-08-09
 * 聊天公屏模块接口
 *
 */

interface ChatRoomApi : IComponentApi {
    /**
     * 发送消息到所有公屏上面
     * @param messageType 消息类型
     * @param uid 用户ID
     * @param userName 用户名
     * @param message 公屏要显示的消息
     * @param props 设置消息的业务透传数据
     * @param callback 回调，发送消息成功或者失败的回调
     */
    fun sendMessage(
        messageType: Int,
        uid: Long,
        userName: String,
        message: String,
        props: HashMap<String, String>?,
        callback: ChatRoomCallback?
    )

    /**
     * 发送消息到自己的公屏上面
     * @param messageType 消息类型
     * @param uid 用户ID
     * @param userName 用户名
     * @param message 公屏要显示的消息
     * @param props 设置消息的业务透传数据
     * @param callback 回调，发送消息成功或者失败的回调
     */
    fun sendMessageToSelf(
        messageType: Int,
        uid: Long,
        message: String?,
        props: HashMap<String, String>?,
        data: Any?,
        callback: ChatRoomCallback?
    )

    fun observerChatMessageForever(observer: Observer<LinkedList<IChatInfo>>)

    fun removeObserver(observer: Observer<LinkedList<IChatInfo>>)

    fun getLastCount(): Int

    /**
     * 添加用户禁言消息回调
     * @param  callback 是否禁言的callback,类型IDisableCallback
     */
    fun addUserChatDisableCallback(callback: IDisableCallback?)

    /**
     * 移除用户禁言消息回调
     */
    fun removeUserChatDisableCallback()

    /**
     * 添加用户消息接收监听函数，添加监听之后，
     * 有用户发消息可以自定义注册函数实现逻辑
     * @param  callback  消息接收监听函数回调，类型IReceiveMessageCallback
     */
    fun addMessageReceiveListener(callback: IReceiveMessageCallback?)

    /**
     * 移除用户消息接收监听函数
    */
    fun removeMessageRecieveListener()

    /**
     * 用户禁言消息回调接口，自行实现onUserMuted，true禁言，false非禁言
     */
    interface IDisableCallback {
        fun onUserMuted(isMute: Boolean) //是否被禁言
    }

    /**
     * 用户消息接收监听接口，自行实现onReceiveMessage
     */
    interface IReceiveMessageCallback {
        fun onReceiveMessage(
                type: Int,
                from: Long,
                topSid: Long,
                userName: String?,
                message: String?,
                props: HashMap<String, String>?
        )
    }

    /**
     * 添加用户消息是否是敏感词回调
     * @param  callback 是否是敏感词的callback,类型ISensitiveWordsCallback
     */
    fun addSensitiveWordsCallback(callback: ISensitiveWordsCallback?)

    /**
     * 移除用户消息敏感词回调
     */
    fun removeSensitiveWordsCallback()

    /**
     * 忽略进场流水消息
     */
    fun ignoreEntranceChannelWaterMessage(ignore: Boolean)

    /**
     * 用户发的消息是否包含敏感词提示回调
     */
    interface ISensitiveWordsCallback {
        fun onSensitiveWords(sensitive: Boolean)
    }

    fun fetchRoamingMessages(limit: Int)

    fun clearChatMessages()
}